|
|
|
|
|
|
|
The following sections walk you through these steps, using a text box as the base control. Your "enhanced" text box will be known as a "Limited Character Text Box." It will have a user-defined property that allows the programmer to choose a set of acceptable characters that the user can enter. This additional property, CharAccept, will allow the user to restrict text entry to only letters, only numbers, or allow both. |
|
|
|
|
|
|
|
|
Setting Up the Base Control |
|
|
|
|
|
|
|
|
The steps for creating the enhanced text control are similar to the steps you used to create the Address control. For the enhanced text control, the steps are as follows: |
|
|
|
|
|
|
|
|
1. Start a new ActiveX Control project. |
|
|
|
|
|
|
|
|
2. Add a text box to the UserControl window, with the upper-left corner of the text box in position 0, 0. |
|
|
|
|
|
|
|
|
3. Name the text box txtCharSet, and clear its Text property. |
|
|
|
|
|
|
|
|
4. Set the properties of the ActiveX project and the UserControl to the values specified in Table 14.1. |
|
|
|
|
| Table 14.1 Settings for the Limited Character TextBox Control | | Item | Setting | | Project Type | ActiveX Control | | Project Name | TextLimited | | Project Description | Text Box for Limited Character Set | | User control Name property | TxtCharLimit | | User control Public property | True |
|
|
|
|
|
|
To set the first three values in the table, use the Properties dialog box (which you access by choosing Project, Properties). To set the remaining values, highlight the UserControl object, and press F4 to show the Properties window. After you set up the user interface of the enhanced text control, it should look like the one in Figure 14.8. |
|
|
|
|
|
|
|
|
Figure 14.8
The base control, pictured here, will be
enhanced with additional capabilities. |
|
|
|
|
|